package d0718;

public class Demo02 implements Runnable {
	private Integer ticks;

	public Demo02(Integer ticks) {

		this.ticks = ticks;
	}

	@Override
	public void run() {
		int c = 0;
		String name = Thread.currentThread().getName();
		while (true) {
			synchronized (ticks) {
				if (ticks <= 0)
					break;
				ticks--;
			}
			c++;
			System.out.println(name + "卖了" + c + "票");
		}
	}
}
